import { applyMiddleware, createStore, compose } from 'redux'
import { createBrowserHistory } from 'history'
import { routerMiddleware } from 'react-router-redux'
import { composeWithDevTools } from 'redux-devtools-extension'
import thunk from 'redux-thunk'
import reducer from './reducer'
import initial from './initial'

const history = createBrowserHistory()
const middleware = routerMiddleware(history)

const applys = (applyMiddleware(thunk), applyMiddleware(middleware))

const create = compose(
  __ACTIVE_REDUCEDR_TOOLS__ ? composeWithDevTools(applys) : applys
)(createStore)

const store = create(reducer, initial)

export default store
